﻿using System;
using System.Collections.Generic;
using System.Collections;

namespace Hanhud.Web.UI
{
    public class SitePageCollection : CollectionBase
    {
        public virtual SitePage this[int index]
        {
            get
            {
                return (SitePage)List[index];
            }
            set
            {
                List[index] = value;
            }
        }

        public virtual SitePage this[string name]
        {
            get
            {
                return GetSitePageByName(name);
            }
            set
            {
                for (int i = 0; i < List.Count; i++)
                    if (string.Compare(name, (List[i] as SitePage).Name, StringComparison.CurrentCultureIgnoreCase ) == 0)
                        List[i] = value;
            }
        }

        public void Add(SitePage page)
        {

        }

        public void Add(string name)
        {

        }

        internal bool Remove(int index)
        {
            return false;
        }

        internal bool Remove(string name)
        {
            return false;
        }

        internal bool Remove(SitePage page)
        {
            return false;
        }

        private SitePage GetSitePageByName(string name)
        {
            for (int i = 0; i < List.Count; i++)
                if (string.Compare(name, (List[i] as SitePage).Name, true) == 0)
                    return (SitePage)List[i];
            return null;
        }
    }
}
